﻿// Copyright © Microsoft Corporation.  All Rights Reserved.
// This code released under the terms of the 
// Microsoft Public License (MS-PL, http://opensource.org/licenses/ms-pl.html.)


using System.Windows;

namespace WpfPowerManagement
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        private void powerWatcher1_BatteryLifePercentChanged(object sender, BaseLibrary.Power.PowerEventArgs e)
        {
            ShowBatteryStatus(e);
        }

        private void powerWatcher1_PowerPersonalityChanged(object sender, BaseLibrary.Power.PowerEventArgs e)
        {
            ShowBatteryStatus(e);
        }

        private void powerWatcher1_PowerSourceChanged(object sender, BaseLibrary.Power.PowerEventArgs e)
        {
            ShowBatteryStatus(e);
        }

        private void ShowBatteryStatus(BaseLibrary.Power.PowerEventArgs e)
        {
            string text = "Ladezustand: " + e.BatteryLifePercent.ToString() + " %";
            //text += "Stromquelle: " + e.PowerSource;
            textBlock1.Text = text;
        }
    }
}
